'use strict';
const BaseController = require('./base');
const serviceName = 'message';

class MessageController extends BaseController {
    constructor(ctx) {
        super(ctx, serviceName);
    }

    // 获取消息列表
    async index() {
        const { ctx } = this;
        const { conversation_id, last_message_id, pageSize = 20 } = ctx.query;

        try {
            const result = await ctx.service.message.getMessagesByLastId(
                conversation_id,
                last_message_id,
                Number(pageSize)
            );
            this.ctx.success(result);
        } catch (error) {
           this.ctx.error()
        }
    }
}

module.exports = MessageController;
